package com.work.music.controller;

import com.work.music.common.HttpRequestParamter;
import com.work.music.service.MusicManagerService;
import com.work.music.utils.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by xs on 2019/4/16.
 */
@Controller
public class IndexController {
    @Autowired
    private MusicManagerService musicManagerService;

    @RequestMapping({"/login.html", "/"})
    public String login() {
        return "view/login";
    }

    @RequestMapping("/acp/index.html")
    public ModelAndView adminIndex() {
        ModelAndView modelAndView = new ModelAndView("view/index");
        modelAndView.addObject("admin", ContextUtil.getAttribute("admin"));
        return modelAndView;
    }

    /**
     * 跳转至歌手列表页面
     * @return
     */
    @RequestMapping("acp/music/songsterlist.html")
    public String songsterlist() {
        return "view/music/songsterlist";
    }

    /**
     * 跳转至歌手详情页面
     * @return
     */
    @RequestMapping("acp/music/songsterEdit.html")
    public ModelAndView songsteredit() {
        ModelAndView modelAndView = new ModelAndView("view/music/songsteredit");
        modelAndView.addObject("songster", musicManagerService.getSongsterById(HttpRequestParamter.getLong("id", -1)));
        return modelAndView;
    }

    /**
     * 跳转至专辑列表页面
     * @return
     */
    @RequestMapping("acp/music/albumlist.html")
    public String albumlist() {
        return "view/music/albumlist";
    }

    /**
     * 跳转至专辑详情页面
     * @return
     */
    @RequestMapping("acp/music/albumEdit.html")
    public ModelAndView albumEdit() {
        ModelAndView modelAndView = new ModelAndView("view/music/albumedit");
        modelAndView.addObject("album", musicManagerService.getAlbumById(HttpRequestParamter.getLong("id", -1)));
        return modelAndView;
    }

    /**
     * 跳转至专辑列表页面
     * @return
     */
    @RequestMapping("acp/music/lyricslist.html")
    public String lyricslist() {
        return "view/music/lyricslist";
    }

    /**
     * 跳转至用户列表页面
     * @return
     */
    @RequestMapping("acp/music/userlist.html")
    public String userlist() {
        return "view/music/userlist";
    }

    /**
     * 跳转至专辑详情页面
     * @return
     */
    @RequestMapping("acp/music/lyricsEdit.html")
    public ModelAndView lyricsEdit() {
        ModelAndView modelAndView = new ModelAndView("view/music/lyricsedit");
        modelAndView.addObject("lyrics", musicManagerService.getLyricsById(HttpRequestParamter.getLong("id", -1)));
        return modelAndView;
    }

    /**
     * 跳转至积分类型列表页面
     * @return
     */
    @RequestMapping("acp/music/integraltypelist.html")
    public String integraltypelist() {
        return "view/music/integraltypelist";
    }

    /**
     * 跳转至积分类型修改页面
     * @return
     */
    @RequestMapping("acp/music/integraltypeEdit.html")
    public ModelAndView integraltypeEdit() {
        ModelAndView modelAndView = new ModelAndView("view/music/integraltypeEdit");
        modelAndView.addObject("integraltype", musicManagerService.integraltypeById());
        return modelAndView;
    }
}
